#!/usr/bin/env python
# -*- coding: utf8 -*-
# Filename: count_category30_train_data_num.py
# Author: xul - 294739212@qq.com
# Description: 
# Create: 2017-03-19 16:00:13

import collections

lines = open('../data/test_p1.txt').readlines()
category30 = open('../category_30.txt').readlines()
d = collections.defaultdict(int)

with open('../category_30.txt', 'w') as f:
    for category in category30:
        category1 = category.split('\t:\t')[0].strip()
        for line in lines:
            if category1 == line.split('\t:\t')[1]:
                d[category1] += 1

        f.write(category.strip()+'\t:\t'+str(d[category1])+'\n')

